////////////////////////////////////////////////////////////////////////////////////////
//
// JSimpleSim - A machine language simulator based on SimpSim by Anne-Gert Bultena.
//
// Copyright (C) 2008 Gerardo Camorlinga, Ryan Fitzgerald, and RJ Gordon
//
// This file is part of JSimpleSim.
//
// JSimpleSim is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// JSimpleSim is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JSimpleSim.  If not, see <http://www.gnu.org/licenses/>.
//
////////////////////////////////////////////////////////////////////////////////////////

/*
 * clearView.java
 *
 * Created on October 27, 2008, 5:56 PM
 */
package jsimplesim.view;

import org.jdesktop.application.Action;

/**
 *
 * @author  rg820649
 */
public class clearView extends javax.swing.JFrame {

    /**
	 * 
	 */
	private static final long serialVersionUID = -330678234443456257L;
	/**
     *
     */
    public JSimpleSimView view;

    /** Creates new form clearView */
    public clearView() {
        initComponents();
        this.setLocationRelativeTo(null);
    }

    /**
     *
     * @param view1
     */
    public clearView(JSimpleSimView view1) {
        view = view1;
        initComponents();
        this.setLocationRelativeTo(null);
        this.setResizable(false);
    }

    /**
     *
     */
    public void clearReg() {
        view.clearReg();
    }

    /**
     *
     */
    public void clearMem() {
        view.clearMemoryTable();
    }

    /**
     *
     */
    public void clearPc() {
        view.clearPC();
    }

    /**
     *
     */
    public void clearConsole() {
        view.clearConsole();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        chkMem = new javax.swing.JCheckBox();
        chkReg = new javax.swing.JCheckBox();
        chkPc = new javax.swing.JCheckBox();
        btnClear = new javax.swing.JButton();
        btnClose = new javax.swing.JButton();
        chkConsole = new javax.swing.JCheckBox();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(jsimplesim.JSimpleSimApp.class).getContext().getResourceMap(clearView.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel1.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), resourceMap.getColor("jPanel1.border.titleColor"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        chkMem.setText(resourceMap.getString("chkMem.text")); // NOI18N
        chkMem.setName("chkMem"); // NOI18N

        chkReg.setText(resourceMap.getString("chkReg.text")); // NOI18N
        chkReg.setName("chkReg"); // NOI18N

        chkPc.setText(resourceMap.getString("chkPc.text")); // NOI18N
        chkPc.setName("chkPc"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(jsimplesim.JSimpleSimApp.class).getContext().getActionMap(clearView.class, this);
        btnClear.setAction(actionMap.get("clearButtonPressed")); // NOI18N
        btnClear.setText(resourceMap.getString("btnClear.text")); // NOI18N
        btnClear.setName("btnClear"); // NOI18N

        btnClose.setAction(actionMap.get("btnClosePressed")); // NOI18N
        btnClose.setText(resourceMap.getString("btnClose.text")); // NOI18N
        btnClose.setName("btnClose"); // NOI18N

        chkConsole.setText(resourceMap.getString("chkConsole.text")); // NOI18N
        chkConsole.setName("chkConsole"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chkConsole)
                    .addComponent(chkMem)
                    .addComponent(chkReg)
                    .addComponent(chkPc)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnClear)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnClose)))
                .addContainerGap(11, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(chkMem)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chkReg)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chkPc)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chkConsole)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnClear)
                    .addComponent(btnClose)))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new clearView().setVisible(true);
            }
        });
    }

    /**
     *
     */
    @Action
    public void clearButtonPressed() {
        if (chkMem.isSelected()) {
            clearMem();
        }
        if (chkReg.isSelected()) {
            clearReg();
        }
        if (chkPc.isSelected()) {
            clearPc();
        }
        if (chkConsole.isSelected()) {
            clearConsole();
        }
        this.setVisible(false);
    }

    /**
     *
     */
    @Action
    public void btnClosePressed() {
        this.setVisible(false);
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnClear;
    private javax.swing.JButton btnClose;
    private javax.swing.JCheckBox chkConsole;
    private javax.swing.JCheckBox chkMem;
    private javax.swing.JCheckBox chkPc;
    private javax.swing.JCheckBox chkReg;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
}
